package wb.is.besti.edu.cd.emergency_responsesys.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import wb.is.besti.edu.cd.emergency_responsesys.R;
import wb.is.besti.edu.cd.emergency_responsesys.utils.Events;
import wb.is.besti.edu.cd.emergency_responsesys.utils.MarkeInfo;

public class EventActivity extends AppCompatActivity {
    private TextView maintitle;
    private TextView title;
    private TextView dateAndLocal;
    private TextView des;
    private ImageView back;
    private TextView position;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.event_activity);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar!=null){
            actionBar.hide();
        }
        initView();
        initButton();
        Intent intent = getIntent();
        MarkeInfo info = (MarkeInfo)intent.getSerializableExtra("event");
        Events events = info.getEvents();
        setView(events);

    }

    public static Intent newIntent(Context context, MarkeInfo markeInfo){

        Intent intent = new Intent(context,EventActivity.class);
        intent.putExtra("event",markeInfo);
        return intent;
    }

    private void initView(){
        maintitle = (TextView)findViewById(R.id.common_tv_title);
        back = (ImageView)findViewById(R.id.common_iv_back);
        dateAndLocal = (TextView)findViewById(R.id.event_time);
        title = (TextView)findViewById(R.id.event_title);
        des = (TextView)findViewById(R.id.event_des);
        position = (TextView)findViewById(R.id.event_position);
    }
    private void setView(Events events){
        maintitle.setText("信息查看");
        dateAndLocal.setText(events.getTime());
        title.setText(events.getTitle());
        des.setText(events.getDesc());
        position.setText(events.getPosition());
    }
    private void initButton(){
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
